package Demo;

import java.util.concurrent.CountDownLatch;

public class Demo02 {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch latch = new CountDownLatch(10);
        Runnable task = () -> {
            System.out.println("任务开始");
            try {
                Thread.sleep(6000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            latch.countDown();
        };
        for (int i = 0; i < 10; i++) {
            Thread t = new Thread(task);
            t.start();
        }
        latch.await();
        System.out.println("任务结束");
    }
}
